#include<bits/stdc++.h>
using namespace std;
long long n[15],a[15][1000050];
int T,sum[100]={0};
int main(){
freopen("color.in","r",stdin);
freopen("color.out","w",stdout);
cin>>T;
for(int i=1;i<=T;i++){
   cin>>n[i];
   for(int j=1;j<=n[i];j++){
      cin>>a[i][j];
   }
}
for(int i=1;i<=T;i++){
   for(int j=1;j<=n[i];j++){
      for(int k=j+1;k<=n[i];k++){
      if(a[i][j]==a[i][k]) sum[i]++;
      }
   }
   if(sum[i]==0) cout<<0<<endl;
   else if(n[i]==8) cout<<8<<endl;
   else cout<<1<<endl;
}
return 0;
}
